package com.xjt.query.dao.impl;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.xjt.common.StringUtils;
import com.xjt.query.dao.interf.DisplayPlusInfoDao;
import com.xjt.query.dao.pojo.DisplayPlusInfo;

public class DisplayPlusInfoDaoImpl extends SqlMapClientDaoSupport implements DisplayPlusInfoDao {

    @Override
    public DisplayPlusInfo selectInfoByKey(String key) {
        if (StringUtils.isBlank(key)) {
            return null;
        }
        DisplayPlusInfo info = new DisplayPlusInfo();
        info.setKeyWord(key);
        List<DisplayPlusInfo> list = queryPlusInfoList(info);
        if (CollectionUtils.isNotEmpty(list)) {
            return list.get(0);
        }
        return null;
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<DisplayPlusInfo> queryPlusInfoList(DisplayPlusInfo info) {
        List<DisplayPlusInfo> list = getSqlMapClientTemplate().queryForList("display_plus_info.queryPlusInfoList", info);
        return list;
    }
}
